<?php include incTemplate('header.php'); ?>
<script type="text/javascript">
var menuarray ='<?php echo $menulist;?>';		
var menuadds = '<?php echo $menulist;?>';
var cookpifix = '<?php echo $sysinfo['cookpifix'];?>';
var menulist = '<?php echo $menulist;?>';
$(function(){
	$(".menu ul li").hover(
	  function () {
	    $(this).find(".toggle").show();
	    $(this).css("color","#D54E21");

		var fdiv = $(this).find("div.item")[0];
		if(fdiv==undefined){
			return;
		}
		var icon = $(fdiv).attr("class");
		icon = icon.replace("menu-img","");
		icon = icon.replace("item","")
		icon = icon.replace(/(^\s*)|(\s*$)/g,"");

		var defaultPoint = [];
		var p = $(this).find("."+icon).css("background-position");

		if (typeof (p) == "undefined") { 
			defaultPoint[0] = $(this).find("."+icon).css("background-position-x"); 
			var x = defaultPoint[0];
			$(this).find("."+icon).css("background-position",""+x+" 0px");
		} else {
			defaultPoint = p.split(" "); 
			var x = defaultPoint[0];
			$(this).find("."+icon).css("background-position",x+" 0px");
		} 
	  },
	  function () {
	    $(this).find(".toggle").hide();
	    $(this).css("color","#21759B");

	    var fdiv = $(this).find("div.item")[0];
		if(fdiv==undefined){
			return;
		}
		var icon = $(fdiv).attr("class");
		icon = icon.replace("menu-img","");
		icon = icon.replace("item","")
		icon = icon.replace(/(^\s*)|(\s*$)/g,"");

		var defaultPoint = [];
		var p = $(this).find("."+icon).css("background-position");
		if (typeof (p) == "undefined") { 
			defaultPoint[0] = $(this).find("."+icon).css("background-position-x"); 
			var x = defaultPoint[0];
			$(this).find("."+icon).css("background-position",""+x+" -33px");
		} else {
			defaultPoint = p.split(" "); 
			var x = defaultPoint[0];
			$(this).find("."+icon).css("background-position",x+" -33px");
		}
	  }
	);

	$(".toggle").click(function(dt){
		var itemlist = $(this).parent("li").find(".itemlist");
		var display = itemlist.css("display");
		var tg = $(this).attr("id");
		var temparray = [];
		if(display == 'none'){
			$(this).show();
			var exist = false;
			if(menuadds.length>=1){
				for(var i=0;i<menuadds.length;i++){
					if(menuadds[i]==tg){
						exist = true;
					}
				}
			}

			if(!exist){
				if(menuadds!=""){
					menuadds = menuadds+","+tg;
				}else{
					menuadds = tg;
				}
				
			}
			itemlist.css('display','block');
		}else{
			$(this).hide();
			if(menuadds!=""){
				var newmenulist = "";
				menuadds = menuadds.replace(tg,"");
				var itemlists = menuadds.split(',');
				for(var i=0;i<itemlists.length;i++){
					if(itemlists[i]!=""){
						if(newmenulist == ""){
							newmenulist +=itemlists[i];
						}else{
							newmenulist +=","+itemlists[i];
						}
					}
				}
				menuadds = newmenulist;
			}else{
				menuadds = ""; 
			}
			itemlist.css('display','none');
		}

		//设置cookie
		var cookstr = menuadds;
		
		var today = new Date();
		var expireDay = new Date();
		var msPerMonth = 24*60*60*1000*31;
		expireDay.setTime( today.getTime() + msPerMonth );

        var expdate = new Date();
        expdate.setTime(expdate.getTime() - (86400 * 1000 * 1));
		setCookie(cookpifix+"menulist", "", expdate); 
		deleteCookie(cookpifix+"menulist");
		document.cookie = cookpifix+"menulist="+cookstr+";domain=localhost;expires=" + expireDay.toGMTString();
		//alert(cookpifix+"menulist="+cookstr+";expires=" + expireDay.toGMTString()+";path=/");
		
	});

	$(".itemlist ul li").hover(
  	  function () {
	    $(this).addClass("itemhover");
	    $(this).css("color","#000");
	  },
	  function () {
	    $(this).removeClass("itemhover");
	    $(this).css("color","#21759B");
	  }
	);

	//找到第一个menu-arrow，设置icon的样式
	var fdiv = $(".menu-arrow").parent("li").find("div.menu-img");
	if(fdiv!=undefined){
		var icon = fdiv.attr("class");
		icon = icon.replace("menu-img","");
		icon = icon.replace("item","")
		icon = icon.replace(/(^\s*)|(\s*$)/g,"");

		var defaultPoint = [];
		var p = fdiv.parent("li").find("."+icon).css("background-position");
		if (typeof (p) == "undefined") { 
			defaultPoint[0] = fdiv.parent("li").find("."+icon).css("background-position-x"); 
			var x = defaultPoint[0];
			fdiv.parent("li").find("."+icon).css("background-position",""+x+" 0px");
		} else {
			defaultPoint = p.split(" "); 
			var x = defaultPoint[0];
			fdiv.parent("li").find("."+icon).css("background-position",x+" 0px");
		}
	}

	//设置显示的菜单
	if(menulist!=""){
		var menuarray = menulist.split(',');
		if(menuarray.length>=1){
			for(var i=0;i<menuarray.length;i++){
				$("#"+menuarray[i]).parent("li").find("div.itemlist").css('display','block');
				$("#"+menuarray[i]).parent("li").find(".toggle").show();
			}
		}
	}
	
});
</script>
</head>
<body>
<div class="console">
<?php include incTemplate('menulist.php'); ?>
<div class="content">
	<div class="bk_head">
	<span class="fl webname"><?php echo $sysinfo['sys_name'];?></span>
	<span class="fr">您好：<?php echo $_SESSION['adminlogin']['login_name'];?></span>
	</div>
	<div class="bk_body">